﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Admin_AddCateNews : System.Web.UI.Page
{
    CategoryNewsController categoryNews = new CategoryNewsController();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        CategoryNews cn = new CategoryNews();
        cn.Name = txtName.Text;
        cn.Url = txtUrl.Text;
        cn.Order = Convert.ToInt32(txtOrder.Text);
        if(ddlStatus.SelectedIndex==0)
        {
            cn.Status = true;
        }
        else
        {
            cn.Status = false;
        }
        if(categoryNews.Insert(cn)>0)
        {
            Response.Write("<script>alert('Thêm thành công')</script>");
            txtName.Text = "";
            txtOrder.Text = "";
            txtUrl.Text = "";
            ddlStatus.SelectedIndex = 0;
        }
        else
        {
            Response.Write("<script>alert('Thêm bị gặp lỗi')</script>");
            return;
        }
    }
}